package com.health.ts.controller.patientview;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.health.ts.constant.ApiResult;
import com.health.ts.controller.BaseController;
import com.health.ts.entity.patientview.StPacsStudyinfo;
import com.health.ts.entity.patientview.StPatientBaseinfo;
import com.health.ts.entity.patientview.StTestResult;
import com.health.ts.service.patientview.StDrugOrdersService;
import com.health.ts.service.patientview.StPacsStudyinfoService;
import com.health.ts.service.patientview.StPatientBaseinfoService;
import com.health.ts.service.patientview.StTestResultService;
import com.health.ts.utils.AssertUtil;
/**
 * <p>
 *  患者一体化视图接口
 * </p>
 *
 * @author ${ts}
 * @since 2017-09-16
 */
@RestController
@RequestMapping(value = "/api/patientView",produces= BaseController.JSON_UTF8)
public class PatientViewController extends BaseController{
	
	@Autowired
	StPatientBaseinfoService  patientBaseinfoService;
	
	@Autowired
	StDrugOrdersService drugOrdersService;
	
	@Autowired
	StTestResultService testResultService;
	
	@Autowired
	StPacsStudyinfoService studyinfoService;
	
	/**
	 * 获取患者基本信息
	 * @param patientId
	 * @return
	 */
	@RequestMapping(value="/baseInfo/{patientId}", method=RequestMethod.GET)
	public ApiResult getPatientBaseInfo(@PathVariable String patientId) {
		StPatientBaseinfo patientInfo = patientBaseinfoService.getPatientBaseInfo(patientId);
		AssertUtil.notNull(patientInfo, "根据患者编号【"+patientId+"】没有找到患者信息");
		return ApiResult.success(patientInfo);
	}
	
	/**
	 * 获取患者医嘱列表
	 * @param patientId
	 * @return
	 */
	@RequestMapping(value="/drugOrders/{patientId}", method=RequestMethod.GET)
	public ApiResult getDrugOrders(@PathVariable String patientId) {
		return ApiResult.success(drugOrdersService.getDrugOrders(patientId));
	}
	
	/**
	 * 获取患者检验名列表
	 * @param patientId
	 * @return
	 */
	@RequestMapping(value="/testResults/{patientId}/orderNames", method=RequestMethod.GET)
	public ApiResult getTestOrderNames(@PathVariable String patientId) {
		List<StTestResult> result = testResultService.getTestOrderNameList(patientId);
		return ApiResult.success(result);
	}
	
	/**
	 * 获取患者检验项目列表
	 * @param patientId
	 * @return
	 */
	@RequestMapping(value="/testResults/{patientId}/orderItems", method=RequestMethod.GET)
	public ApiResult getTestOrderItems(@PathVariable String patientId,String orderId) {
		List<StTestResult> result = testResultService.getTestOrderItemList(patientId, orderId);
		return ApiResult.success(result);
	}
	
	/**
	 * 获取患者PACS检查项目列表
	 * @param patientId
	 * @return
	 */
	@RequestMapping(value="/pacscheck/{patientId}", method=RequestMethod.GET)
	public ApiResult getPacsCheckList(@PathVariable String patientId) {
		List<StPacsStudyinfo> result = studyinfoService.getStudyList(patientId);
		return ApiResult.success(result);
	}
}
